import React from 'react'
import LoginStore from './login'
import UserStore from './user'
import ChannelStore from './channel'

// 把所有的模块统一处理
// 导出一个统一的方法useStore

class RootStore {
  constructor() {
    // 挂起东西: class是个类，继承new它
    this.loginStore = new LoginStore()
    this.userStore = new UserStore()
    this.channelStore = new ChannelStore()
  }
}

// 实例化根
// 导出useStore context
const rootStore = new RootStore()
const context = React.createContext(rootStore)

const useStore = ()=> React.useContext(context)

export { useStore }